<?php
include ("header.php");
?>
<script type="text/javascript" src="jscripts/view.js"></script>
<script type="text/javascript" src="jscripts/calendar.js"></script>
<body id="form">


<div id="form_container">
<form id="form_158019" class="appnitro" method="post"
	action="update_info.php">


<?php

if (! isset ( $_SESSION ['modified'] )) {
	if (isset ( $_SESSION ['editInfo'] )) {
		
		$firstName = $_SESSION ['firstName'];
		$lastName = $_SESSION ['lastName'];
		$areaCode = $_SESSION ['areaCode'];
		$phoneNum = $_SESSION ['phoneNum'];
		$phoneNum2 = $_SESSION ['phoneNum2'];
		$street = $_SESSION ['street'];
		$street2 = $_SESSION ['street2'];
		$city = $_SESSION ['city'];
		$zipcode = $_SESSION ['zipcode'];
		$email = $_SESSION ['email'];
		$times = $_SESSION ['times'];
		$foodinfo = $_SESSION ['food_info'];
		$addInfo = $_SESSION ['addInfo'];
		$category = $_SESSION ['category'];
		$output = <<<END
<div class="form_description">
<h2>Update Information</h2>
<p>Fill out this form to update your information</p>
</div>
<ul>

	<!-- Organization
	<li id="li_0"><label class="description" for="element_0">Organization</label>
		<span>
			<input id="element_0" name="org" class="element text large"
			value="" type="text" size = "20">
		</span>
	</li>
	<!-- Name -->
	<li id="li_1"><label class="description" for="element_1">Contact Person</label>
	<!-- First Name -->
		<span>
			<input id="element_1_1" name="first_name" class="element text" maxlength="255" size="8" value='$firstName' />
				<label>First Name</label>
		</span>
	<!-- Last Name -->
		<span>
			<input id="element_1_2" name="last_name" class="element text" maxlength="255" size="14" value='$lastName' />
				<label>Last Name</label>
			</span>
	</li>
	<!-- Phone Number -->
	<li id="li_2">
		<label class="description" for="element_2">Phone </label>
			<span>
				<input id="element_2_1" name="phone_num1" class="element text"
				size="3" maxlength="3" value='$areaCode' type="text"> -
				<label for="element_2_1">(###)</label>
			</span>
			<span>
				<input id="element_2_2" name="phone_num2" class="element text"
				size="3" maxlength="3" value='$phoneNum' type="text"> -
				<label for="element_2_2">###</label>
			</span>
			<span>
				<input id="element_2_3" name="phone_num3" class="element text"
				size="4"maxlength="4"value='$phoneNum2' type="text">
				<label for="element_2_3">####</label>
			</span>
	</li>
	<!-- Address -->
	<li id="li_3">
		<label class="description" for="element_3">Address </label>
		<div>
			<input id="element_3_1" name="street_address" class="element text large"
			value='$street' type="text">
			<label for="element_3_1">Street Address</label>
		</div>
		<div>
			<input id="element_3_2" name="line2" class="element text large"
			value='$street2' type="text">
			<label for="element_3_2">Address Line 2</label>
		</div>
	
		<div class="left">
			<input id="element_3_3" name="city"
			class="element text medium" value='$city' type="text">
			<label for="element_3_3">City</label>
		</div>
	<!--  
		<div class="right">
			<input id="element_3_4" name="state"
			class="element text medium" maxlength="15" value="" type="text">
			<label for="element_3_4">State</label>
		</div>
	-->
		<div class ="left">
			<input id="element_3_5" name="zipcode" class="element text medium"
			maxlength="15" value='$zipcode' type="text">
			<label for="element_3_5">Postal / Zip Code</label>
		</div>
	</li>
	<!-- Email -->
	<li id="li_4">
		<label class="description" for="element_4">Email </label>
		<div>
			<input id="element_4" name="email" class="element text medium"
			type="text" maxlength="255" value='$email' />
		</div>
	</li>
	<!-- Organization type -->
	<li id="li_5">
		<label class="description" for="element_5">Organization Type </label>
		<div>
			<input class="element text small" id="element_5" name="category" type ="radio" value ="farm"
END;
		if ($category == "farm")
			$output .= "checked";
		
		$output .= <<<END
/>Farm<br>
			<input class="element text small" id="element_5" name="category" type ="radio" value ="farmers_market" 
END;
		if ($category == "farmers_market")
			$output .= "checked";
		$output .= <<<END
/>Farmer's Market<br>
			<input class="element text small" id="element_5" name="category" type ="radio" value ="community_garden" 
END;
		if ($category == "community_garden")
			$output .= "checked";
		
		$output .= <<<END
/>Community Garden<br>
			<input class="element text small" id="element_5" name="category" type ="radio" value ="orchard" 
END;
		if ($category == "orchards")
			$output .= "checked";
		$output .= <<<END
/>Orchard<br>
			<input class="element text small" id="element_5" name="category" type ="radio" value ="csa" 
END;
		if ($category == "csa")
			$output .= "checked";
		
		$output .= <<<END
/>CSA<br>
			<input class="element text small" id="element_5" name="category" type ="radio" value ="other" 
END;
		if ($category == "other")
			$output .= "checked";
		
		$output .= <<<END
	/>Other<br>
		</div>
	</li>
	<!-- times-->
		<li id="li_6">
		<label class="description" for="element_6">Times available. </label>
		<div>
			<textarea id="element_6" name="times"
			class="element textarea medium">$times</textarea>
		</div>
		<p class="guidelines" id="guide_6">
			<small>
				Please enter the days of the week
			 	and times you are avaialable.
			 </small>
			</p>
	</li>
	<!-- Tree Info -->
	<li id="li_7">
		<label class="description" for="element_7">Food Information</label>
		<div>
			<textarea id="element_10" name="tree_info" class="element textarea medium">$foodinfo</textarea>
		</div>
		<p class="guidelines" id="guide_10"><small>What kind of food do you have?</small></p>
	</li>
	<!-- Equipment
	<li id="li_8">
		<label class="description" for="element_8">Equipment available on site. </label>
		<span>
			<input id="element_8_1"	name="ladder" class="element checkbox" type="checkbox" value="1" />
			<label class="choice" for="element_8_1">Ladder</label>
			<input id="element_8_2" name="element_8_2" class="element checkbox" type="checkbox" value="1" />
			<label class="choice" for="extension_cord">Extension Cord</label>
		</span>
		<p class="guidelines" id="guide_8">
			<small>
				What equipment can you
				provide on site to help harvest?
			</small>
		</p>
	</li>
	<!-- website
		<li id="li_10"><label class="description" for="element_8">Website Address </label>
		<div>
			<input id="element_10" name="website" class="element text medium" type="text" maxlength="255" value="http://" />
		</div>
	</li>
	<!-- Additional Information -->
	<li id="li_9"><label class="description" for="element_9">Additional information </label>
		<div>
			<textarea id="element_9" name="add_info" class="element textarea medium">$addInfo</textarea>
		</div>
		<p class="guidelines" id="guide_9">
			<small>
				Is there anything other information
				you would like to add?
			</small>
		</p>
	</li>
	<!-- delete? -->
	<li id="li_12">
		<label class="description" for="element_12">Do you wish to delete this entry?</label>
		<div>
			<input class="element text small" id="element_12" name="delete" type ="radio" value ="true" />Yes<br>
			<input class="element text small" id="element_12" name="delete" type ="radio" value ="false" checked />No<br>
		</div>
		<p class="guidelines" id="guide_8">
			<medium>
				Deleting this entry can not be undone, are you sure you want your information removed?
			</medium>
		</p>
	</li>
		<!-- password -->
	<li id="li_11">
		<label class="description" for="element_11">Password </label>
		<div>
			<input id="element_11" name="password" class="elment text medium"
			type="password" maxlength="255" value="" />
		</div>
				<p class="guidelines" id="guide_11">
			<small>
				Enter your password again to confirm these changes. 
			</small>
		</p>
	</li>

	<li class="buttons"><input type="hidden" name="form_id" value="158019" />

	<input id="saveForm" class="button_text" type="submit" name="submit"
		value="Submit" /></li>
</ul>
END;
	
	} else {
		$output = <<<END
		<div class="form_description">	
			<h2>Organization Update</h2>
			<p>Please Enter the Address and password of the Organization you wish to update.</p>
		</div>							
			<ul >
			
		<li id="li_2" >

		<label class="description" for="Address">Address </label>
		
		<div>
			<input id="streetAdd" name="streetAdd" class="element text large" value='' type="text"/>
			<label for="streetAdd">Street Address</label>
		</div>
	
		<div>
			<input id="add2" name="add2" class="element text large" value='' type="text"/>
			<label for="add2">Address Line 2</label>

		</div>
	
		<div class="left">
			<input id="city" name="city" class="element text medium" value='' type="text"/>
			<label for="city">City</label>
		</div>
	
		<div class="left">
			<input id="zip" name="zip" class="element text medium" maxlength="5" value='' type="text"  />
			<label for="zip">Zip Code</label>
		</div>
	
		
		</li>
		<li id="li_11" >
		<label class="description" for="lblPassword">Password: </label>
		<div>
			<input id="password" name="password" class="element text medium" type="password" maxlength="255" value=""/> 
			<label for="password">Password</label>
		</div><p class="guidelines" id="passwordGuide"><small>Please enter the password you registered with.</small></p> 
		</li>	
			
					<li class="buttons">
			    <input type="hidden" name="form_id" value="159998" />
			    
				<input id="saveForm" class="button_text" type="submit" name="submit" value="Submit" />
				
		</li>

		</ul>

END;
	
	}
	
	echo $output;
}
if (isset ( $_SESSION ['error'] )) {
	echo $_SESSION ['error'];
	unset ( $_SESSION ['error'] );
}

if (isSet ( $_SESSION ['success'] )) {
	session_unset ();
	session_destroy ();
}

?>
	</form>
</div>
</body>
<?php
include ("footer.php");
?>



